from typing import List, Tuple
def main():
NONE_DAY: int = -100
exm_cnt: int = int(input().strip())
table: List[Tuple[int, int]] = list()
for pos in range(0, exm_cnt):
inn: List[str] = input().strip().split(' ')
left: int = int(inn[0])
right: int = int(inn[1])
elem: Tuple[int, int] = (left, right)
table.append(elem)
table.sort()
last_exm_day_cnt: int = NONE_DAY
for pos in range(0, exm_cnt):
if last_exm_day_cnt <= table[pos][1]:
last_exm_day_cnt = table[pos][1]
else:
last_exm_day_cnt = table[pos][0]
print(last_exm_day_cnt)
main()
#include<bits/stdc++.h>
using namespace std;
constexpr int INF = 2100000000;
typedef long long ll;
typedef unsigned long long ULL;
constexpr ll INF64 = 1e18;
const int N = 2e5+10;
typedef pair<int, int> PII;
#define mysort(a) sort(a.begin(),a.end());
void solve() {
int n;
cin >> n;
vector<PII> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
mysort(a);
int res = 0;
for (int i = 0; i < n; i++) {
int t = min(a[i].first, a[i].second);
if (t < res) {
res = max(a[i].first, a[i].second);
}
else {
res = t;
}
}
cout << res << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
solve();
return 0;
}
1088B - Ehab and subtraction | 1270B - Interesting Subarray |
478C - Table Decorations | 1304C - Air Conditioner |
1311C - Perform the Combo | 1519C - Berland Regional |
361A - Levko and Table | 5E - Bindian Signalizing |
687A - NP-Hard Problem | 1542C - Strange Function |
961E - Tufurama | 129D - String |
888A - Local Extrema | 722B - Verse Pattern |
278A - Circle Line | 940A - Points on the line |
1742C - Stripes | 1742F - Smaller |
1742B - Increasing | 1742A - Sum |
1742D - Coprime | 390A - Inna and Alarm Clock |
1398B - Substring Removal Game | 1742G - Orray |
416B - Art Union | 962A - Equator |
803B - Distances to Zero | 291A - Spyke Talks |
1742E - Scuza | 1506D - Epic Transformation |